package com.orhon.smartcampus.modules.schoolaffairs.entity;


import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import com.orhon.smartcampus.modules.base.entity.Schools;
import com.orhon.smartcampus.modules.user.entity.Users;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "schoolAdministration_formula", schema = "smartcloud", catalog = "")
public class SchoolFormula {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;

    @Column(name = "title", nullable = true, length = 255)
    private String title;

    @Column(name = "created_by", nullable = true)
    private Integer createdBy;

    @Column(name = "created_at", nullable = true)
    private Date createdAt;

    @Column(name = "updated_at", nullable = true)
    private Date updatedAt;

    @Column(name = "deleted_at", nullable = true)
    private Date deletedAt;

    //学校
    @ManyToOne( cascade = CascadeType.ALL , fetch = FetchType.LAZY)
    @JoinColumn(name = "school_id")
    @NotFound(action= NotFoundAction.IGNORE)
    @Where(clause = "ISNULL(deleted_at)")
    private Schools school;

    //发布人
    @ManyToOne( cascade = CascadeType.ALL , fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    @NotFound(action= NotFoundAction.IGNORE)
    @Where(clause = "ISNULL(deleted_at)")
    private Users publisher;

//    //部门
//    @ManyToOne( cascade = CascadeType.ALL , fetch = FetchType.LAZY)
//    @JoinColumn(name = "depart_id")
//    @NotFound(action= NotFoundAction.IGNORE)
//    @Where(clause = "ISNULL(deleted_at)")
//    private OrgDepartments departments;
//
//    //班级
//    @ManyToOne( cascade = CascadeType.ALL , fetch = FetchType.LAZY)
//    @JoinColumn(name = "eclass_id",referencedColumnName = "id")
//    @NotFound(action= NotFoundAction.IGNORE)
//    @Where(clause = "ISNULL(deleted_at)")
//    private Eclass eclass;
//
//
//    /**
//     * 新闻分类关联字典表
//     */
//    @ManyToOne( cascade = CascadeType.ALL , fetch = FetchType.LAZY)
//    @JoinColumn(name = "type", referencedColumnName = "id")
//    @NotFound(action=NotFoundAction.IGNORE)
//    @Where(clause = "ISNULL(deleted_at)")
//    private Dictionary type;

}
